#ifndef WEBSOCKETSERVEREXAMPLE_H
#define WEBSOCKETSERVEREXAMPLE_H

#include "WWebsocketServer.h"
#include "WLog.h"

class WebsocketServerExample: public IWebsocketServerCb
{
public:
    WebsocketServerExample(mg_mgr *mgr = nullptr);
    virtual ~WebsocketServerExample();
    bool startWsServer(int port);
    void run();

    virtual void onWsServerReceiveMsg(mg_connection *wsConnection, shared_ptr<string> receiveMsg);
    virtual void onWsServerConnect(mg_connection *wsConnection);
    virtual void onWsServerClosed(mg_connection *wsConnection);
    virtual bool checkIfValidWs(mg_connection *wsConnection, mg_http_message *hm);

private:
    WWebsocketServer *_websocketServer = nullptr;
};

#endif // WEBSOCKETSERVEREXAMPLE_H
